//
//  MCOrderDetailBottomView.swift
//  StoreManage
//
//  Created by MC on 2017/12/21.
//  Copyright © 2017年 MC. All rights reserved.
//

import UIKit

class MCOrderDetailBottomView: UIView {

    fileprivate var tempIsOnlyOneButton = false
    
    var isOnlyOneButton : Bool {
        get {
            return tempIsOnlyOneButton
        }
        
        set {
            tempIsOnlyOneButton = newValue
            
            if tempIsOnlyOneButton {
                leftButton.isHidden = true
                
                rightButton.snp.remakeConstraints { (make) ->Void in
                    make.right.top.bottom.equalTo(self)
                    make.width.equalTo(MCScreenWidth)
                }

            } else {
                leftButton.isHidden = false
                
                leftButton.snp.remakeConstraints { (make) ->Void in
                    make.left.top.bottom.equalTo(self)
                    make.width.equalTo(MCScreenWidth/2)
                }
                
                rightButton.snp.remakeConstraints { (make) ->Void in
                    make.right.top.bottom.equalTo(self)
                    make.width.equalTo(MCScreenWidth/2)
                }

            }
        }
    }
    
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        backgroundColor = UIColor.white
        

        self.addSubview(leftButton)
        leftButton.snp.remakeConstraints { (make) ->Void in
            make.left.top.bottom.equalTo(self)
            make.width.equalTo(MCScreenWidth/2)
        }
        
        self.addSubview(rightButton)
        rightButton.snp.remakeConstraints { (make) ->Void in
            make.right.top.bottom.equalTo(self)
            make.width.equalTo(MCScreenWidth/2)
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    
    lazy var leftButton: UIButton = {
        let button = UIButton.init(type: UIButtonType.custom)
        button.backgroundColor = UIColor.MCAssist
        button.titleLabel?.font = MCFont(14)
        button.setTitle("left", for: UIControlState.normal)
        button.setTitleColor(UIColor.white, for: UIControlState.normal)
        return button
    }()
 
    
    lazy var rightButton: UIButton = {
        let button = UIButton.init(type: UIButtonType.custom)
        button.backgroundColor = UIColor.MCMain
        button.titleLabel?.font = MCFont(14)
        button.setTitle("right", for: UIControlState.normal)
        button.setTitleColor(UIColor.white, for: UIControlState.normal)
        return button
    }()
}
